﻿using MapleLeaf.DataBase.Repository;
using MapleLeaf.Model.CookBook.Organization.Entity;
using MapleLeaf.Model.CookBook.Organization.Relation;
using MapleLeaf.Service.CookBook.Interface;
using SqlSugar;

namespace MapleLeaf.Service.CookBook.Organization {
    /// <summary>
    /// 
    /// </summary>
    public class SysRoleService(ISqlSugarClient db) : DataBaseRepository<RoleEntity>(db), IScopedService {
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public async Task<List<RoleEntity>> GetRoleListByUserId(long userId) {
            var roles = await Context.Queryable<RoleEntity>()
                .InnerJoin<UserRoleEntity>((i, r) => i.Id == r.RoleId)
                .Where((i, r) => r.UserId == userId).ToListAsync();
            return roles;
        }
    }
}
